import { uploadType, getAreaObj } from '@/utils/util'
import { configToSearch, toSearchHandle } from '@/views/datacenter/business/utils/index'

const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{ label: '所属区域', prop: 'belongAreaName' },
		{ label: '证件号码', prop: 'idCard',plusXing: '2,2' },
		{ label: '发放对象', prop: 'name' },
		{ label: '联系方式', prop: 'phone',plusXing: '5,2' },
		{ label: '发放金额', prop: 'subsidyTotalAmountLower' },
		{
			label: '补贴岗位类型',
			prop: 'positionType',
			propName: 'positionTypeLabel',
			code: 'SUBSIDY_POSITION_TYPE',
			api: 'getDictItemList',
			type: 'remoteSelect',
		},
		// {
		// 	label: '工作单位统一社会信用代码',
		// 	prop: 'creditCode',
		// },
		{
			label: '工作单位',
			prop: 'unitName',
		},
		{
			label: '区民政审批时间',
			prop: 'civilAdministrationAuditTime',
		},
		{
			label: '是否可信',
			prop: 'isBelievable',
			custome: 'tag',
			dicData: [
				{ label: '否', value: 0,type:'danger' },
				{ label: '是', value: 1,type:'success' },
			],
		},
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}
const importConfig = {
	tabSteps: [
		{
			label: '下载模板',
			download: '下载模板',
			active: 1,
			rules: [
				{
					label: '下载最新导入模板。共1个：',
					children: [
						{
							label: '《从业人员补贴信息表》',
							link: true,
							url: 'dpPractitionersSubsidy_downloadTemplate',
						},
						{
							label: '《从业人员岗位补贴-资格证书》',
							link: true,
							url: 'view_dpPractitionersSubsidyCertificate_downloadTemplate',
						},
					],
				},
			],
		},
		{
			label: '导入《从业人员补贴信息表》',
			description: '',
			uploadTip: '从业人员补贴信息表',
			active: 2,
			url: 'dpPractitionersSubsidy_import',
			code: 2016,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的从业人员补贴信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
		{
			label: '导入《从业人员岗位补贴-资格证书》',
			description: '',
			uploadTip: '从业人员岗位补贴-资格证书',
			active: 3,
			url: 'view_dpPractitionersSubsidyCertificate_import',
			code: 2026,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的从业人员补贴信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
	],
}

export const detailConfig: any = {
	label: '从业人员补贴详情',
	prop: 'base1',
	inline: false,
	showBtn: false,
	labelPosition: 'left',
	column: [
		// 基础信息
		{
			type: 'DividerHtml',
			modelValue: '基础信息',
			span: 24,
		},
		{
			label: '补贴岗位类型',
			prop: 'positionType',
			propName: 'positionTypeLabel',
			code: 'SUBSIDY_POSITION_TYPE',
			api: 'getDictItemList',
			type: 'remoteSelect',
			span: 8,
		},
		{
			label: '老人照片',
			prop: 'img',
			type: 'upload',
			showFileList: false,
			limit: 9,
			multiple: true,
			span: 8,
		},
		{
			label: '姓名',
			prop: 'name',
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '性别',
			prop: 'gender',
			propName: 'genderLabel',
			type: 'remoteSelect',
			api: 'getDictItemList',
			code: 'GENDER',
			span: 8,
		},
		{
			label: '身份证号',
			prop: 'idCard',
			type: 'text',
			maxlength: '18',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '所属区划',
			prop: 'areas_name',
			type: 'AplidAreaSelect',
			span: 8,
		},
		{
			label: '民族',
			prop: 'nationality',
			propName: 'nationalityLabel',
			type: 'remoteSelect',
			api: 'getDictItemList',
			code: 'NATIONALITY',
			span: 8,
		},
		{
			label: '出生年月',
			prop: 'birthday',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			span: 8,
		},
		{
			label: '文化程度',
			prop: 'cultureDegree',
			propName: 'cultureDegreeLabel',
			api: 'getDictItemList',
			code: 'EDUCATION_DEGREE',
			type: 'remoteSelect',
			span: 8,
		},
		{
			label: '联系电话',
			prop: 'phone',
			type: 'text',
			maxlength: '11',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '毕业院校',
			prop: 'graduationInstitution',
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '申请学历',
			prop: 'applyBackground',
			propName: 'applyBackgroundLabel',
			code: 'APPLYING_FOR_EDUCATIONAL_BACKGROUND',
			api: 'getDictItemList',
			type: 'remoteSelect',
			span: 8,
		},
		{
			label: '开户银行',
			prop: 'bankName',
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '银行卡号',
			prop: 'bankAccount',
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
			span: 8,
		},

		// 申请信息
		{
			type: 'DividerHtml',
			modelValue: '申请信息',
			span: 24,
		},
		{
			label: '养老工作起始年月',
			prop: 'participateElderlyTime',
			type: 'month',
			format: 'YYYY年MM月',
			valueFormat: 'YYYYMM',
			span: 8,
		},
		{
			label: '从业社会保险连续缴纳起始年月',
			prop: 'insurancePayStart',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			span: 8,
		},
		{
			label: '已领取奖励总金额',
			prop: 'getAwardTotalAmount',
			type: 'text',
			append: '元',
			span: 8,
		},
		{
			label: '已领取年限',
			prop: 'getTerm',
			type: 'text',
			append: '年',
			span: 8,
		},
		{
			label: '申请领取奖励金额',
			prop: 'applyGetAwardTotalAmount',
			type: 'text',
			append: '元',
			span: 8,
		},
		{
			label: '申请领取年度',
			prop: 'applyGetTerm',
			type: 'text',
			append: '年',
			span: 8,
		},
		{
			label: '资格证书',
			type: 'dynamic',
			prop: 'certificateList',
			span: 24,
			column: [
				{
					label: '资格证书名称',
					prop: 'certificateName',
					type: 'text',
					maxlength: '50',
					showWordLimit: true,
					span: 8,
				},
				{
					label: '资格证书编号',
					prop: 'certificateNumber',
					type: 'text',
					maxlength: '50',
					showWordLimit: true,
					span: 8,
				},
			],
		},
		{
			label: '（上年度）10月份补贴金额',
			prop: 'octoberSubsidyAmount',
			type: 'text',
			append: '元',
			span: 8,
		},
		{
			label: '（上年度）11月份补贴金额',
			prop: 'novemberSubsidyAmount',
			type: 'text',
			append: '元',
			span: 8,
		},
		{
			label: '（上年度）12月份补贴金额',
			prop: 'decemberSubsidyAmount',
			type: 'text',
			append: '元',
			span: 8,
		},
		{
			label: '1月份补贴金额',
			prop: 'januarySubsidyAmount',
			type: 'text',
			append: '元',
			span: 8,
		},
		{
			label: '2月份补贴金额',
			prop: 'februarySubsidyAmount',
			type: 'text',
			append: '元',
			span: 8,
		},
		{
			label: '3月份补贴金额',
			prop: 'marchSubsidyAmount',
			type: 'text',
			append: '元',
			span: 8,
		},
		{
			label: '4月份补贴金额',
			prop: 'aprilSubsidyAmount',
			type: 'text',
			append: '元',
			span: 8,
		},
		{
			label: '5月份补贴金额',
			prop: 'maySubsidyAmount',
			type: 'text',
			append: '元',
			span: 8,
		},
		{
			label: '6月份补贴金额',
			prop: 'juneSubsidyAmount',
			type: 'text',
			append: '元',
			span: 8,
		},
		{
			label: '7月份补贴金额',
			prop: 'julySubsidyAmount',
			type: 'text',
			append: '元',
			span: 8,
		},
		{
			label: '8月份补贴金额',
			prop: 'augustSubsidyAmount',
			type: 'text',
			append: '元',
			span: 8,
		},
		{
			label: '9月份补贴金额',
			prop: 'septemberSubsidyAmount',
			type: 'text',
			append: '元',
			span: 8,
		},
		{
			label: '用人单位名称',
			prop: 'unitName',
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '用人单位名称统一社会信用代码',
			prop: 'creditCode',
			type: 'text',
			maxlength: '18',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '用人单位地址',
			prop: 'unitAddress',
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '补贴总金额(小写）',
			prop: 'subsidyTotalAmountLower',
			type: 'text',
			append: '元',
			span: 8,
		},
		{
			label: '补贴总金额(大写）',
			prop: 'subsidyTotalAmountUpper',
			type: 'text',
			span: 8,
		},

		// 审批信息
		{
			type: 'DividerHtml',
			modelValue: '审批信息',
			span: 24,
		},

		{
			label: '用人单位审批意见',
			prop: 'unitApproveOpinion',
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '用人单位意见审批时间',
			prop: 'unitApproveOpinionTime',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			span: 8,
		},
		{
			label: '区民政局审批意见',
			prop: 'civilAdministrationOpinion',
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '区民政局审批时间',
			prop: 'civilAdministrationAuditTime',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			span: 8,
		},
		{
			label: '区财政局审批意见',
			prop: 'treasuryDeptOpinion',
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '区财政局审批时间',
			prop: 'treasuryDeptAuditTime',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			span: 8,
		},
		//  申请材料
		{
			type: 'DividerHtml',
			modelValue: '申请材料',
			span: 24,
		},
		{
			label: '申请人信息承诺书',
			prop: 'applyPromise',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			showFileList: true,
			limit: 9,
			multiple: true,
			span: 8,
		},
		{
			label: '用人单位信息承诺书',
			prop: 'unitPromise',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			showFileList: true,
			limit: 9,
			multiple: true,
			span: 8,
		},
		{
			label: '学历证书',
			prop: 'academicCertificate',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			showFileList: true,
			limit: 9,
			multiple: true,
			span: 8,
		},
		{
			label: '养老护理员证书(含行业培训证书）',
			prop: 'nursingCertificate',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			showFileList: true,
			limit: 9,
			multiple: true,
			span: 8,
		},
		{
			label: '护士执业资格证书',
			prop: 'nurseQualificationCertificate',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			showFileList: true,
			limit: 9,
			multiple: true,
			span: 8,
		},
		{
			label: '康复治疗(理疗)师证书',
			prop: 'rehabilitationCertificate',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			showFileList: true,
			limit: 9,
			multiple: true,
			span: 8,
		},
		{
			label: '双方签订劳动合同',
			prop: 'laborContract',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			showFileList: true,
			limit: 9,
			multiple: true,
			span: 8,
		},
		{
			label: '双方签订劳务派遣协议',
			prop: 'dispatchAgreement',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			showFileList: true,
			limit: 9,
			multiple: true,
			span: 8,
		},
		{
			label: '社会保险(连续缴满两年）',
			prop: 'socialInsurance',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			showFileList: true,
			limit: 9,
			multiple: true,
			span: 8,
		},
		{
			label: '养老服务机构从业人员岗位津贴申请表',
			prop: 'positionAllowance',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			showFileList: true,
			limit: 9,
			multiple: true,
			span: 8,
		},
		{
			label: '养老护理岗位工作人员入职奖励申请表',
			prop: 'awardApply',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			showFileList: true,
			limit: 9,
			multiple: true,
			span: 8,
		},
		{
			label: '养老护理员行业培训证书（或护士执业资格证书、康复治疗师证书、康复理疗师证书',
			prop: 'trainingCertificate',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			showFileList: true,
			limit: 9,
			multiple: true,
			span: 8,
		},
		// 审批结果
		{
			type: 'DividerHtml',
			modelValue: '审批结果',
			span: 24,
		},
		{
			label: '审批人',
			prop: 'approveUser',
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '审批时间',
			prop: 'approveTime',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			span: 8,
		},
		{
			label: '补贴发放总金额(大写）',
			prop: 'subsidyGrantTotalAmountUpper',
			type: 'text',
			span: 8,
		},
		{
			label: '补贴发放时间',
			prop: 'subsidyGrantTime',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			span: 8,
		},
	],
}
const moreSearchConfig: any = {
	inline: true,
	showBtn: false,
	labelPosition: 'left',
	column: [...configToSearch(detailConfig.column)],
}
export const baseConfig: any = {
	pageName: '从业人员补贴',
	dictcodes: ['SUBSIDY_POSITION_TYPE', 'GENDER', 'NATIONALITY', 'EDUCATION_DEGREE', 'APPLYING_FOR_EDUCATIONAL_BACKGROUND'],
	rowKey: 'id',
	tipLabel: 'name',
	// exportMqTopic: '/ning/export',
	exportMqTopic: [
		{
			topic: '/ning/export/dpPractitionersSubsidy/',
			label: '从业人员补贴信息',
			code: 2016,
			po: 'dpPractitionersSubsidyPO',
		},
		{
			topic: '/ning/export/dpPractitionersSubsidyCertificate/',
			label: '从业人员岗位补贴-资格证书',
			code: 2026,
			po: 'dpPractitionersSubsidyCertificatePO',
		},
	],
	api: {
		moreSearch: 'view_dpPractitionersSubsidy_search',
		index: 'dpPractitionersSubsidy_page',
		delete: 'dpPractitionersSubsidy_del',
		export: 'view_dpPractitionersSubsidy_exportAll',
		import: 'dpPractitionersSubsidy_import',
	},
	auth: {
		index: 'view_dpPractitionersSubsidy_page',
		mulitSet: 'mulitSet',
		delete: 'view_dpPractitionersSubsidy_del',
		// export: 'view_dpPractitionersSubsidy_exportAll',
		// import: 'view_dpPractitionersSubsidy_import',
	},
	paramsObj: {
		code: 2016,
	},
	menuBtn: [
		{
			icon: 'editor',
			label: '查看详情',
			type: 'primary',
			operate: 'Detail',
			auth: '',
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '65%',
	},
	moreSearchConfig,
	searchConfig: {
		inline: true,
		showBtn: true,
		labelPosition: 'left',
		column: [
			{
				label: '证件号码',
				prop: 'idCard',
				type: 'input',
				span: 6,
			},
			{
				label: '发放对象',
				prop: 'name',
				type: 'input',
				span: 6,
			},
			{
				label: '联系方式',
				prop: 'phone',
				type: 'input',
				span: 6,
			},
			{
				label: '所属地区',
				propName: 'areas_name',
				type: 'AplidAreaSelect',
				span: 6,
			},
			{
				label: '补贴岗位类型',
				prop: 'positionType',
				propName: 'positionTypeLabel',
				type: 'remoteSelect',
				api: 'geiDictItemList',
				code: 'SUBSIDY_POSITION_TYPE',
				multiple: false,
				filterKey: 'value',
				span: 6,
			},
			{
				label: '区民政审批时间',
				prop: 'civilAdminTimeBetween',
				type: 'daterange',
				format: 'YYYY年MM月DD日',
				valueFormat: 'YYYY-MM-DD',
				span: 12,
			},
		],
	},
	detailConfig,
	tableConfig,
	importConfig,
	beforeOnLoadFormate: async (params) => {
		params = toSearchHandle(moreSearchConfig, {}, params)
		if (params.civilAdminTimeBetween) {
			params.civilAdminTimeBetween = params.civilAdminTimeBetween.join(',')
		}
		let areasObj = getAreaObj(params.areas_name, 'belong')
		return Promise.resolve({
			...params,
			...areasObj,
			areas_name: undefined,
		})
	},
	onLoadFormate: async (arr) => {
		console.log('参数二', arr)
		const tableData = arr.map((item) => {
			const areas_name = getAreaObj(item, 'belong')
			return {
				...item,
				areas_name,
			}
		})
		return Promise.resolve(Object.freeze(tableData))
	},
}
